<?php
function carte($id, $nb){
    
global $connexion_bd;

require_once '../inc/fpdf/fpdf.php';
require_once '../inc/configuration.php';
require_once '../inc/connexion_db.php';

if (isset($_GET['id'])) {
$id = $_GET['id'];}
$id = mysqli_real_escape_string($connexion_bd, $id);
$sql = "SELECT * FROM entreprises, contacts WHERE entreprises.id = contacts.id_entreprise AND contacts.id=$id"; 
$req = mysqli_query($connexion_bd, $sql) or die('Erreur SQL !'.$req.'<br>'.mysql_error());
$datacv = mysqli_fetch_array($req);

$pdf = new FPDF();
for ($i=0;$i<8;$i++){
$pdf->AddPage("L", [88,110]); //[145,110]

//$x=0;
//if($x<1) {$y=0; ++$x; } else {$x=0; $y=1;}

$pdf->SetFillColor(127);
$pdf->Rect(13, 43, 85, 3, 'F');  //30, 55, 85, 3,
$pdf->SetFillColor(210);
$pdf->Rect(13, 46, 85, 21, 'F');  //30, 58, 85, 21, 
//$pdf->SetMargins('1,35','2');
//$pdf->SetAutoPageBreak(true);
        
//        $pdf->image("../contacts/photos/bouteille_bateau.jpg",15,15, -1900);
        $pdf->image("../..".$datacv['photo'],15,15, -140);
        
        $pdf->setXY(52,16); //46,16  63,28
        $pdf->SetFont('Arial','B',14);
        $pdf->SetTextColor(0);
	$pdf->MultiCell(35,5, $datacv['raison_sociale'] . "\n" ,0,'L');
        
        $pdf->setXY(52,18);  //46,18  63,30
        $pdf->SetFont('Arial','',12);
        $pdf->MultiCell(43,5,"\n" . $datacv['adresse'] ,0,'L');	
 
	$pdf->setXY(14,55);  //14,55  31,67
	$pdf->SetFont('Arial','',12);
	$pdf->Cell(24,6,$datacv['nom'] . " " . $datacv['prenom'],0,1);
        
        $pdf->setXY(14,61); //14,61  31,73
        $pdf->SetFont('Arial','',9);
	$pdf->SetTextColor(38, 97, 156);
	$pdf->Cell(18,6,$datacv['email'],0,1);
        
        $pdf->setXY(14,47); //14,47  31,59
	$pdf->SetTextColor(0);
	$pdf->MultiCell(60,3,$datacv['observations'],0,'L');
       
        $pdf->setXY(77,46); //77,46  94,58
	$pdf->SetTextColor(15, 5, 107);
	$pdf->Cell(18,6,$datacv['telephone'],0,1);
 
	$pdf->setXY(13,13); //13,13  30,25
	$pdf->Cell(85,54,'',1,1);
        
}
$pdf->SetDisplayMode('fullpage');
$pdf->Output(time().'carte_de_visite.pdf','I');

}
